<?php
class Comment extends Public_Controller{
	function __construct(){
		parent::__construct();
		$this->load->model('comment_m');
	}
	
	public function insert(){
		$json = array();
		$model = $this->input->post();
		$this->form_validation->set_rules('full_name', lang('global:title'), 'trim|required|max_length[30]');
		$this->form_validation->set_rules('content', lang('global:content'), 'trim|required|max_length[300]|min_length[6]');
		if ($this->form_validation->run() == TRUE)
		{
			$id_insert = $this->comment_m->insert($model);
			$json['id']  = $id_insert;
		}
		else{
			$json['error'] = validation_errors('<p class="error"> - ', '</p>');
		}
		
		echo json_encode($json);
		
		
		
	}
}